home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CHARTP10.ARJ / EDGE.H < prev    next >
C/C++ Source or Header  |  1992-01-26  |  2KB  |  78 lines

  1.  
  2. // Copyright 1992, David Perelman-Hall & Jamshid Afshar
  3.  
  4.  
  5. #ifndef EDGE_H
  6. #define EDGE_H
  7.  
  8. #include "category.h"
  9. #include "tree.h"
  10.  
  11.  
  12. class Edge {
  13. friend Edge combine( const Edge& edge1, const Edge& edge2 );
  14. friend ostream& operator << ( ostream& os, const Edge& edge );
  15. private:
  16.    int _start;
  17.    int _finish;
  18.    Tree _tree;
  19.    Category_Sequence _toFind;
  20. public:
  21.    // constructor
  22.    Edge( int start, int finish, const Category& label );
  23.  
  24.    // constructor
  25.    Edge( int start, int finish, const Category& label,
  26.                const Category_Sequence& toFind );
  27.    
  28.    // constructor
  29.    Edge( int start, int finish, const Tree& tree,
  30.                const Category_Sequence& toFind );
  31.  
  32.    // copy constructor
  33.    Edge( const Edge& edge );
  34.    // assignment operator
  35.    void operator = ( const Edge& edge );
  36.    bool operator == ( const Edge& edge ) const;
  37.    bool canCombineWith( const Edge& edge ) const;
  38.    bool isActive() const{ return !_toFind.isEmpty(); }
  39.    int start() const { return _start; }
  40.    int finish() const { return _finish; }
  41.    Category label() const { return _tree.cat(); }
  42.    Category_Sequence found() const { return _tree.get_children(); }
  43.    const Category_Sequence& toFind() const { return _toFind; }
  44.    const Tree& parse() const { return _tree; }
  45. };
  46.  
  47.  
  48. class Edge_List {
  49. friend ostream& operator << ( ostream& os, const Edge_List& list );
  50. private:
  51.    struct edgeNode{
  52.       Edge _edge;
  53.       edgeNode *_next;
  54.       edgeNode( const Edge& edge, edgeNode *next)
  55.          : _edge(edge), _next(next) {}
  56.       };
  57.    edgeNode *_firstNode;
  58. public:
  59.    // constructor
  60.    Edge_List();
  61.    // copy constructor
  62.    Edge_List( const Edge_List& edge_List );
  63.    // destructor
  64.    ~Edge_List();
  65.  
  66.    void push( const Edge& edge );
  67.    Edge pop();
  68.    // assignment operator 
  69.    void operator = ( const Edge_List& edge_List );
  70.    void clear();
  71.  
  72.    bool isMember( const Edge& edge ) const;
  73.    bool isEmpty() const;
  74. };
  75.  
  76.  
  77. #endif
  78.